use tauri::{AppHandle, RunEvent};

use crate::components;

pub(crate) fn app_event_handler(_: &AppHandle, event: RunEvent) {
    match event {
        RunEvent::Exit => {
            let result = components::v2ray::manager::manager().stop();
            if result.is_err() {
                log::error!("停止V2ray-Core失败: {}", result.unwrap_err().to_string());
            }
        }
        RunEvent::ExitRequested { api, .. } => {
            api.prevent_exit();
        }
        RunEvent::WindowEvent { .. } => {}
        RunEvent::Ready => {}
        RunEvent::Resumed => {}
        RunEvent::MainEventsCleared => {}
        _ => {}
    }
}